<template>
  <button
    ref="_ref"
    class="daai-button"
    :class="{
      [`daai-button--${type}`]: type,
      [`daai-button--${size}`]: size,
      'is-plain': plain,
      'is-round': round,
      'is-circle': circle,
      'is-disabled': disabled || loading,
    }"
    :disabled="disabled || loading"
  >
    <Daai-Icon v-if="loading" icon="spinner" spin />
    <Daai-Icon v-if="icon" :icon="icon" />
    <span v-if="$slots.default">
      <slot></slot>
    </span>
  </button>
</template>

<script setup>
import { ref } from 'vue'
import propTypes from './props'
defineOptions({
  name: 'DaaiButton',
})
const props = defineProps(propTypes)

const _ref = ref(null)
defineExpose({ ref: _ref }) // 向外暴露根 ref
</script>

<style lang="scss" scoped></style>
